luci-mod-status: reorganize include load function for status page
authorChristian Marangi <[email protected]>
Tue, 21 Nov 2023 20:43:43 +0000 (21:43 +0100)
committerPaul Donald <[email protected]>
Thu, 2 Oct 2025 12:57:50 +0000 (14:57 +0200)
Reorganize include load function for status page an move it inside view
extend index page.

Signed-off-by: Christian Marangi <[email protected]>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js

index f19a5e4f5de450390868036d086f7981cc6dbd63..a232f315c01255d051777329105e5266e0819e0e 100644 (file)
@@ -5,30 +5,30 @@
 'require fs';
 'require network';
 
-function invokeIncludesLoad(includes) {
-       var tasks = [], has_load = false;
+return view.extend({
+       invokeIncludesLoad: function(includes) {
+               var tasks = [], has_load = false;
 
-       for (var i = 0; i < includes.length; i++) {
-               if (typeof(includes[i].load) == 'function') {
-                       tasks.push(includes[i].load().catch(L.bind(function() {
-                               this.failed = true;
-                       }, includes[i])));
+               for (var i = 0; i < includes.length; i++) {
+                       if (typeof(includes[i].load) == 'function') {
+                               tasks.push(includes[i].load().catch(L.bind(function() {
+                                       this.failed = true;
+                               }, includes[i])));
 
-                       has_load = true;
-               }
-               else {
-                       tasks.push(null);
+                               has_load = true;
+                       }
+                       else {
+                               tasks.push(null);
+                       }
                }
-       }
 
-       return has_load ? Promise.all(tasks) : Promise.resolve(null);
-}
+               return has_load ? Promise.all(tasks) : Promise.resolve(null);
+       },
 
-return view.extend({
        poll_status: function(includes, containers) {
-               return network.flushCache().then(function() {
-                       return invokeIncludesLoad(includes);
-               }).then(function(results) {
+               return network.flushCache().then(L.bind(
+                       this.invokeIncludesLoad, this, includes
+               )).then(function(results) {
                        for (var i = 0; i < includes.length; i++) {
                                var content = null;